package com.example.bank.repository;

import com.example.bank.entity.Transaction;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface TransactionRepository extends JpaRepository<Transaction, Long> {
    
    List<Transaction> findByAccount_number(Long accountNumber);
    
    List<Transaction> findByAccount_numberAndType(Long accountNumber, String type);
    
    @Query("SELECT t FROM Transaction t WHERE t.account_number = ?1 AND t.transactionDate >= ?2 AND t.transactionDate <= ?3")
    List<Transaction> findByAccount_numberAndDateBetween(Long accountNumber, LocalDateTime startDate, LocalDateTime endDate);
    
    List<Transaction> findByAccount_numberAndTypeAndTransactionDateBetween(
            Long accountNumber, String type, LocalDateTime startDate, LocalDateTime endDate);
} 